package com.jl.jlapp.wxapi;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.alibaba.fastjson.JSON;
import com.jl.jlapp.eneity.WXAccessTokenEntity;
import com.jl.jlapp.eneity.WXBaseRespEntity;
import com.jl.jlapp.eneity.WXUserInfo;
import com.jl.jlapp.nets.Api;
import com.jl.jlapp.nets.CommonObserver;
import com.jl.jlapp.nets.Net;
import com.jl.jlapp.nets.Transformer;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;

import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class WXEntryActivity extends AppCompatActivity implements IWXAPIEventHandler {
    private IWXAPI api;

    private void getUserInfo(WXAccessTokenEntity paramWXAccessTokenEntity) {
        Net.get("https://api.weixin.qq.com/").getUserInfo(paramWXAccessTokenEntity.getAccess_token(), paramWXAccessTokenEntity.getOpenid())
                .compose(Transformer.<WXUserInfo>switchSchedulers())
                .subscribe(new CommonObserver<WXUserInfo>() {
                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(WXUserInfo wxUserInfo) {

                    }
                });
    }

    protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent) {
        super.onActivityResult(paramInt1, paramInt2, paramIntent);
        this.api.handleIntent(paramIntent, this);
    }

    protected void onCreate(@Nullable Bundle paramBundle) {
        super.onCreate(paramBundle);
        this.api = WXAPIFactory.createWXAPI(this, "wx037454184aee70e9", true);
        this.api.registerApp("wx037454184aee70e9");
        Log.d("111111", "--------------------------------");
        if (!this.api.handleIntent(getIntent(), this)) {
            Log.d("111111", "参数不合法，未被SDK处理，退出");
            finish();
        }
    }

    protected void onNewIntent(Intent paramIntent) {
        super.onNewIntent(paramIntent);
        setIntent(paramIntent);
        this.api.handleIntent(paramIntent, this);
        finish();
    }

    public void onReq(BaseReq paramBaseReq) {
        Log.d("baseReq:", JSON.toJSONString(paramBaseReq));
    }

    public void onResp(BaseResp paramBaseResp) {
        Log.d("baseResp:--A", JSON.toJSONString(paramBaseResp));
        Log.d("baseResp--B:", paramBaseResp.errStr + "," + paramBaseResp.openId + "," + paramBaseResp.transaction + "," + paramBaseResp.errCode);
        WXBaseRespEntity localWXBaseRespEntity = (WXBaseRespEntity) JSON.parseObject(JSON.toJSONString(paramBaseResp), WXBaseRespEntity.class);
        switch (paramBaseResp.errCode) {
            case 0:
                Net.get("https://api.weixin.qq.com/").getAccessToken("wx037454184aee70e9", "cbdab39fdc019dac230045a25e745ae1", localWXBaseRespEntity.getCode(), "authorization_code")
                        .compose(Transformer.<WXAccessTokenEntity>switchSchedulers())
                        .subscribe(new CommonObserver<WXAccessTokenEntity>() {
                            @Override
                            protected void onError(String errorMsg) {

                            }

                            @Override
                            protected void onSuccess(WXAccessTokenEntity wxAccessTokenEntity) {

                            }
                        });
                break;
            case -2:
                finish();
                break;
            case -4:
                finish();
                break;
        }
    }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/wxapi/WXEntryActivity.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */